package thread;

/**
 * 获取线程相关信息的一组方法.
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();
        /**获取线程的名字*/
        String name = main.getName();
        System.out.println("name："+name);
        /**获取线程的唯一标识  相当于ID*/
        long id = main.getId();
        System.out.println("id:"+id);
        /**获取线程的优先级*/
        int priority = main.getPriority();
        System.out.println("优先级:"+priority);

        /**线程是否活着-------run()方法结束则死了*/
        boolean isAlive = main.isAlive();
        /**是否为守护线程*/
        boolean isDaemon = main.isDaemon();
        /**是否被中断了*/
        boolean isInterrupted = main.isInterrupted();
        System.out.println("isAlive:"+isAlive);
        System.out.println("isDaemon:"+isDaemon);
        System.out.println("isInterrupted:"+isInterrupted);


    }
}
